﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Gencode.Gengui.Wizzard;

namespace Gencode.PrsUtil.InitWizard
{
    [ToolboxItem(false)]
	public partial class InitMandid : Gencode.Gengui.Wizzard.WizzardControl
	{
		public InitMandid(string previousControl, string nextControl, WizzardDialog controler)
			: base(previousControl, nextControl, controler)
		{
			InitializeComponent();
		}

		public override void InitializeWizzardControl()
		{
			//Do not show Control. Just move to next and add defaultdata
			//This has to be removed if the database should once be used with multiple mandants
			Controler.MoveNext();
		}

		public override bool MoveNext()
		{
			if (txtKuerzel.Text != string.Empty && txtKuerzel.Text.Length == 2 && txtName.Text != string.Empty)
			{
				Gencode.Common.SQL.Querry.SilentTransaction = true;
				Gencode.PrsCommon.Data.Common.CommonData.AddMandant(txtKuerzel.Text, txtName.Text, txtBeschr.Text);
				Gencode.Common.SQL.Querry.SilentTransaction = false;
				Controler.DataObjects.AddType(new InitData() { Mandid = txtKuerzel.Text });

				return true;
			}

			return false;
		}
	}
}
